package com.yitao.cms.controller.user.appUser;

import com.skipper.base.bean.DataOutput;
import com.skipper.base.bean.PagedInput;
import com.skipper.base.bean.PagedOutput;
import com.yitao.cms.service.user.appUser.AppUserService;
import com.yitao.cms.vo.user.appUser.AppUserInfoDetailsVo;
import com.yitao.cms.vo.user.appUser.AppUserInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping(value = "/cms/appUser", produces = {"application/json"})
@Api(description = "查询APP用户相关接口", tags = {"cms-app-user"})
public class AppUserController {


    @Autowired
    private AppUserService appUserService;

    /**
     * 查询用户列表
     */
    @ApiOperation("查询用户列表")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public PagedOutput<AppUserInfoVo> getAppUserList(
            @ApiParam(value = "用户名称", required = false) @RequestParam(value = "userName", required = false) String userName,
            @ApiParam(value = "用户手机号码", required = false) @RequestParam(value = "userPhone", required = false) String userPhone,
            @ApiParam(value = "分页参数，表示当前页", required = true, defaultValue = "1") @RequestParam(value = "pageNo", required = true) Integer pageNo,
            @ApiParam(value = "分页参数，表示每页显示多少条记录", required = true, defaultValue = "10") @RequestParam(value = "pageSize", required = true) Integer pageSize) {
        return appUserService.getAppUserList(userName, userPhone, new PagedInput(pageSize, pageNo));
    }

    /**
     * 详情
     */
    @ApiOperation("查询用户详细信息")
    @RequestMapping(value = "/details", method = RequestMethod.POST)
    public DataOutput<AppUserInfoDetailsVo> getAppUserInfo(
            @ApiParam(value = "用户ID", required = false) @RequestParam(value = "userId", required = false) Long userId) {
        return appUserService.getAppUserInfo(userId);
    }

    /**
     * 禁用或者启用app用户
     */
    @ApiOperation("禁用或者启用app用户")
    @RequestMapping(value = "/disable", method = RequestMethod.POST)
    public DataOutput disableAppUserInfo(
            @ApiParam(value = "用户ID", required = false) @RequestParam(value = "userId", required = false) Long userId) {
        return appUserService.prohibitOrEnableAppUserInfo(userId);
    }

}
